/*
 * @Author: jianghaiyang807
 * @Date:   2016-10-27
 */

const getQuery =  function (name, url) {
  //参数：变量名，url为空则表从当前页面的url中取
  let u = arguments[1] || window.location.search.replace("&amp;", "&").replace(/\/$/, '')
  let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)")
  let r = u.substr(u.indexOf("\?") + 1).match(reg)
  return r != null ? r[2] : ""
}


/**
 * 测试环境内网：https://pss-esales-collect-stg1.paic.com.cn
 §  测试环境外网：https://test-collect.pa18.com:32443
 §  生产环境外网：https://collect.pa18.com
 §  生产环境内网：https://pss-esales-collect.paic.com.cn
 */
// 内网 dev https://pssp-stg1.paic.com.cn
 // 外网 dev https://pssp-dmzstg1.pa18.com:20185
let env = getQuery('env')
let api = 'https://pssp-dmzstg1.pa18.com:20185'
let resultCallbackOrigin = 'https://test-collect.pa18.com:32443/pss-esales-collect'
let protocol_path = 'http://pingan.sd.lenovows.com/common/zeb/pdf'
if (env === 'prd') {
  api = 'https://pssp.pa18.com'
  protocol_path = 'http://salescdn.pa18.com/salesinfo/eLifeAssist/pdf'
  resultCallbackOrigin = 'https://collect.pa18.com/pss-esales-collect'
}



// 接口域名
export const API = api
// 协议预览域名
export const PROTOCOL_PATH = protocol_path
// 协议预览域名
export const RESULT_CALLBACK_ORIGIN = resultCallbackOrigin

// 当前浏览器
let ua = navigator.userAgent.toLocaleLowerCase()
export const isIos = /iphone|ipod|ipad/.test(ua)
export const isWx = ua.indexOf('micromessenger') != -1
export const isAndroid = /android/.test(ua)